
package cn.xd.base.persistence.mps.impl;

import cn.hutool.core.util.ObjUtil;
import cn.xd.base.persistence.dos.AdminRoleDO;
import cn.xd.base.persistence.mapper.AdminRoleMapper;
import cn.xd.base.persistence.mps.AdminRoleMpService;
import cn.xd.common.enums.common.CommonStatusEnum;
import cn.xd.core.response.ObjectResult;
import cn.xd.core.service.impl.BasicMpServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;

@Service
public class AdminRoleMpServiceImpl extends BasicMpServiceImpl<AdminRoleMapper, AdminRoleDO> implements AdminRoleMpService {
    @Override
    public ObjectResult<AdminRoleDO> getAdminRole(String name, Long neId) {
        return getOneForLimitOneResult(Wrappers.lambdaQuery(AdminRoleDO.class)
                .ne(ObjUtil.isNotNull(neId), AdminRoleDO::getId, neId)
                .eq(AdminRoleDO::getName, name)
                .ne(AdminRoleDO::getStatus, CommonStatusEnum.DELETED.getCode()));
    }
}
